import request from '@/utils/request'

// 获取所有的角色列表
export const reqGetRoles = (page = 1, pagesize = 10) => {
  return request({
    method: 'get',
    url: '/sys/role',
    params: {
      page,
      pagesize
    }
  })
}

// 根据id删除角色
export const reqDelRole = (id) => {
  return request({
    method: 'delete',
    url: `/sys/role/${id}`
  })
}

// 新增角色
export const reqAddRole = (data) => {
  return request({
    method: 'post',
    url: '/sys/role',
    data
  })
}

// 根据id获取角色详情
export const reqGetRoleById = (id) => {
  return request({
    method: 'get',
    url: `/sys/role/${id}`
  })
}

// 根据id更新角色
export const reqUpdateRole = (data) => {
  return request({
    method: 'put',
    url: `/sys/role/${data.id}`,
    data
  })
}

// 根据角色id分配权限
export const reqAssignPermission = (id, permIds) => {
  return request({
    method: 'put',
    url: '/sys/role/assignPrem',
    data: {
      id,
      permIds
    }
  })
}
